﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.ComponentModel;

/// <summary>
/// Сводное описание для rqMat
/// </summary>
[DataObject(true)]
public class rqMat
{
    private int _Code;
    private double _Quantity;
    private string _Ed;
    private double _Price;

    public static System.Data.DataTable mat = new System.Data.DataTable();

    public int Code {
        get { return _Code;}
        set { _Code = value; }
        }
    public double Quantity
    {
        get { return _Quantity; }
        set { _Quantity = value; }
    }
    public string Ed
    {
        get { return _Ed; }
        set { _Ed = value; }
    }
    public double Price
    {
        get { return _Price; }
        set { _Price = value; }
    }

	public rqMat()
	{
        Quantity = 0;
        Price = 0;

	}

    public rqMat(int fcode, double fquantity, string fed, double fprice)
    {
        Code = fcode;
        Quantity = fquantity;
        Ed = fed;
        Price = fprice;
    }

    public void AddMat(int fcode, double fquantity, string fed, double fprice)
    {
        Code = fcode;
        Quantity = fquantity;
        Ed = fed;
        Price = fprice;        
    }
    //
    public static System.Data.DataTable Select()
    {
        //System.Data.DataSet ds = new System.Data.DataSet();
        mat.Columns.Add("Code", typeof(Int32));
        mat.Columns.Add("Quantity", typeof(double));
        mat.Columns.Add("Ed", typeof(string));
        mat.Columns.Add("Price", typeof(double));        

        //ds.Tables.Add(mat);
        return mat;
    }
    [DataObjectMethod(DataObjectMethodType.Insert, true)]
    public void Insert(rqMat c)
    {
        // Implement Insert logic
        rqMat c1 = new rqMat(c._Code, c._Quantity, c._Ed, c._Price);
        this.AddMat(c._Code, c._Quantity, c._Ed, c._Price);
    }
    [DataObjectMethod(DataObjectMethodType.Update, true)]
    public void Update(rqMat c)
    {
        // Implement Update logic
    }
    [DataObjectMethod(DataObjectMethodType.Delete, true)]
    public void Delete(rqMat c)
    {
        // Implement Delete logic
        
    }
}

public class MatManager 
{
    public List<rqMat> list_mat = null;
    public  System.Data.DataTable dt_mat = null;

    public MatManager() {
        System.Data.DataTable dt_mat = new System.Data.DataTable();
        dt_mat.Columns.Add("Code", typeof(Int32));
        dt_mat.Columns.Add("Quantity", typeof(double));
        dt_mat.Columns.Add("Ed", typeof(string));
        dt_mat.Columns.Add("Price", typeof(double));
        //rqMat mat = new rqMat();
        List<rqMat> list_mat = new List<rqMat>();    
    }
    public MatManager(List<rqMat> list, DataTable dt)
    {
        //dt_mat = dt;
        //list_mat = list;
        //dt_mat.Columns.Add("Code", typeof(Int32));
        //dt_mat.Columns.Add("Quantity", typeof(double));
        //dt_mat.Columns.Add("Ed", typeof(string));
        //dt_mat.Columns.Add("Price", typeof(double));
        
    }
    public DataTable GetMaterial()
    {
        foreach (rqMat item in list_mat)
        {
            DataRow newRow = dt_mat.NewRow();
            newRow["Code"] = item.Code;
            newRow["Quantity"] = item.Quantity;
            newRow["Ed"] = item.Ed;
            newRow["Price"] = item.Price;
            dt_mat.Rows.Add(newRow);
        }          
        return dt_mat;
    }
    public void Insert(rqMat c)
    {
        list_mat.Add(new rqMat(c.Code, c.Quantity, c.Ed, c.Price));
    }
}